import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_tutorial/app/routes/app_pages.dart';

class AuthMiddleware extends GetMiddleware {
  @override
  int? priority = 0;

  AuthMiddleware({required this.priority});

  @override
  RouteSettings? redirect(String? route) {
    print('==: AuthMiddleware');

    var isLogin = true; // 模拟用户的登录状态
    return isLogin || route == Routes.LOGIN
      ? null
      : RouteSettings(name: Routes.LOGIN);
  }
}